package service

import (
	"gin/common"
	"gin/model"
	"gin/validate"
)

func CreatePlayRole(Data validate.PlayRole) (res model.PlayRole, err error) {
	res.RoleName = Data.RoleName
	res.RoleCode = Data.RoleCode
	res.StoryId = Data.StoryId
	res.RoleId = Data.RoleId
	res.PlayId = Data.PlayId

	_, err = res.Insert()
	return res, err
}

func FindPlayRole(Param common.SelectQueryParam) (resData model.PlayRole, err error) {
	var logModel model.PlayRole
	resData, err = logModel.Find(Param)
	return
}

func SelectPlayRole(Param *common.SelectQueryParam) (total int64, resData []model.PlayRole, err error) {
	var logModel model.PlayRole

	total, resData, err = logModel.Select(Param)

	return
}

func UpdatePlayRole(Data validate.UpdatePlayRoleWrapper) (resData model.PlayRole, err error) {
	return resData.Update(model.PlayRole{
		Id:       Data.Data.Id,
		RoleName: Data.Data.RoleName,
		RoleCode: Data.Data.RoleCode,
		RoleId:   Data.Data.RoleId,
	})
}

func DeletePlayRole(param *common.Filter) {
	var logModel model.PlayRole
	logModel.DeleteByFilter(param)
	return
}
